package com.xinyue.authorization.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xinyue.authorization.bean.Role;
import com.xinyue.authorization.bean.User;
import com.xinyue.authorization.dao.RoleDao;
import com.xinyue.authorization.dao.UserDao;
import com.xinyue.authorization.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService{
	@Autowired
	UserDao dao;
	
	@Autowired
	RoleDao roleDao;

	public void save(User entity) {
		dao.save(entity);
		
		Role r = new Role();
		roleDao.save(r);
	}

	public Integer deleteById(int userId) {
		return dao.deleteById(userId);
	}

	public void update(User entity) {
		dao.update(entity);
	}

	public User queryById(int userId) {
		return dao.queryById(userId);
	}

	public List<User> queryAll(int begin, int count) {
		return dao.queryAll(begin, count);
	}

	public Integer queryCount() {
		return dao.queryCount();
	}
}